﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RiadenieProjektov
{
    public partial class frmPrihlasenie : Form
    {
        public frmPrihlasenie()
        {
            InitializeComponent();
        }

        private void btnPrihlas_Click(object sender, EventArgs e)
        {
            uzivateliaTableAdapterPrihlasenie.Fill(this.dsVsetkoPrihlasenie.uzivatelia);
            DataRow[] riadky = this.dsVsetkoPrihlasenie.uzivatelia.Select("prihlasovacieMeno = '" + 
                txtPrihlasovacieMeno.Text + "' AND heslo = '" + txtHeslo.Text + "'");
            
            if (riadky.Length == 1)
            {
                frmHlavny frmHlavny = new frmHlavny();
                this.Hide();
                frmHlavny.pozicia = (int)riadky[0]["pozicieId"];
                frmHlavny.nastavMenuStrip();
                frmHlavny.ShowDialog();
                this.Show();
            }
            else
            {
                MessageBox.Show("Neprávne prihlásenie", "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void btnKoniec_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
